//===============================================
// Pos Norm Tex Shader
// Reverse tri
//===============================================

cbuffer cbPerObject
{
	matrix g_WVP : WorldViewProjection;
};

Texture2D diffuseTexture : Diffuse;

SamplerState diffuseSampler
{
	Filter = MIN_MAG_MIP_LINEAR;
	AddressU = Clamp;
	AddressV = Clamp;
};

struct VS_INPUT
{
    float3 Pos          : POSITION;         //position
    float2 Tex          : TEXCOORD0;        //texture coordinate
};

struct PS_INPUT
{
    float4 Pos : SV_POSITION;
    float2 Tex : TEXCOORD0;
};


//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS( VS_INPUT input )
{
    PS_INPUT output = (PS_INPUT)0;
    float4 hPos = float4(input.Pos, 1);
    output.Pos = mul(hPos, g_WVP);
    output.Tex = input.Tex;
    
    return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------

float4 PS( PS_INPUT input) : SV_Target
{
	return float4(diffuseTexture.Sample(diffuseSampler, input.Tex).rgb, 1);
}


//--------------------------------------------------------------------------------------
// Technique
//--------------------------------------------------------------------------------------

RasterizerState DisableCulling
{
    CullMode = NONE;
};

DepthStencilState NoDepthStencil
{
	DepthEnable = true;
	StencilEnable = false;
};

BlendState NoBlending
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
    RenderTargetWriteMask[0] = 0x0F;
};

technique10 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
        
        SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
        SetRasterizerState(DisableCulling);       
		SetDepthStencilState(NoDepthStencil, 0);
    }
}

